/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Bari
 */
@Entity
@Table(name = "users")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "User.findAll", query = "SELECT u FROM User u"),
    @NamedQuery(name = "User.findById", query = "SELECT u FROM User u WHERE u.id = :id"),
    @NamedQuery(name = "User.findByIdentifier", query = "SELECT u FROM User u WHERE u.identifier = :identifier")})
public class User implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Size(max = 255)
    @Column(name = "identifier")
    private String identifier;
    @OneToMany(mappedBy = "uid")
    private Collection<ReservationLogs> reservationLogsCollection;
    @OneToMany(mappedBy = "userid")
    private Collection<Activereservation> activereservationCollection;

    public User() {
    }

    public User(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getIdentifier() {
        return identifier;
    }

    public void setIdentifier(String identifier) {
        this.identifier = identifier;
    }

    @XmlTransient
    public Collection<ReservationLogs> getReservationLogsCollection() {
        return reservationLogsCollection;
    }

    public void setReservationLogsCollection(Collection<ReservationLogs> reservationLogsCollection) {
        this.reservationLogsCollection = reservationLogsCollection;
    }

    @XmlTransient
    public Collection<Activereservation> getActivereservationCollection() {
        return activereservationCollection;
    }

    public void setActivereservationCollection(Collection<Activereservation> activereservationCollection) {
        this.activereservationCollection = activereservationCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof User)) {
            return false;
        }
        User other = (User) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entities.User[ id=" + id + " ]";
    }
    
}
